<template>
  <div class="page">
    <div class="head">
      <div class="head-title">
        运单号：{{ orderItem.waybillNo }}
        <Tag  v-show="orderItem.waybillStatus == 0" color="default">待接单</Tag>
        <Tag  v-show="orderItem.waybillStatus == 1" color="magenta">待揽件</Tag>
        <Tag  v-show="orderItem.waybillStatus == 2" color="blue">运输中</Tag>
        <Tag  v-show="orderItem.waybillStatus == 3" color="blue">派送中</Tag>
        <Tag  v-show="orderItem.waybillStatus == 4" color="success">已签收</Tag>
        <Tag  v-show="orderItem.waybillStatus == 5" color="warning">运单撤销</Tag>
        <Tag  v-show="orderItem.waybillStatus == 6" color="warning">退回</Tag>
        <Tag  v-show="orderItem.waybillStatus == 8" color="error">拒签</Tag>
        <Tag  v-show="orderItem.waybillStatus == 10" color="warning">疑难</Tag>
        <Tag  v-show="orderItem.waybillStatus == 11" color="default">订单关闭</Tag>
        <Tag  v-show="orderItem.waybillStatus == 12" color="green">收件中</Tag>
        <Tag  v-show="orderItem.waybillStatus == 13" color="green">已取件</Tag>
        <Tag  v-show="orderItem.waybillStatus == 14" color="warning">揽件失败</Tag>
      </div>
      <div class="head-box">
        <div class="box-item">发货人：{{ orderItem.senderName }}</div>
        <div class="box-item">发货人电话：{{orderItem.senderMobile}}</div>
        <div class="box-item">揽件地址：{{ orderItem.senderAddress }}</div>
      </div>
      <div class="head-box">
        <div class="box-item">收货人：{{ orderItem.recvName }}</div>
        <div class="box-item">收货人电话：{{orderItem.recvMobile}}</div>
        <div class="box-item">收货地址：{{ orderItem.recvAddress }}</div>
      </div>
      <div class="head-box">
        <div class="box-item">物流公司：{{ orderItem.corpName }}</div>
        <div class="box-item">快递员：{{traceVo.expressMan}}</div>
        <div class="box-item">快递员电话：{{traceVo.expressMan}}</div>
      </div>
      <div class="head-box">
        <div class="box-item">计价重量：{{traceVo.feeWeight}}</div>
        <div class="box-item">计价体积：{{traceVo.feeVolume}}</div>
        <div class="box-item">面单链接：{{ traceVo.printLink }}</div>
      </div>
      <div class="head-box">
        <div class="box-item">取件码：{{ traceVo.pickupCode }}</div>
        <div class="box-item">网点电话：{{traceVo.stationMobile}}</div>
        <div class="box-item">发单时间：{{ timestampToTime(orderItem.postTime) }}</div>
      </div>
    </div>
    <Divider>物流跟踪情况</Divider>
    <div class="main">
      <Table border :columns="columns" :data="dataGrid"></Table>
    </div>
  </div>
</template>
<script>
export default {
  name: "detail",
  props: {
    orderItem: Object,
    callbank: Function
  },
  data() {
    return {
      traceVo: {},
      dataGrid: [],
      columns: [
        {
          title: "序号",
          key: "index",
          width: 120,
        },
        {
          title: "时间",
          key: "ftime",
          width: 220,
        },
        {
          title: "物流情况",
          key: "context",
        }
      ]
    };
  },
  created() {},
  methods: {
    init(tmsOrderId) {
      new this.$rest({
        gateway: 'agroerp',
        service: "agroerp-tms",
        url: "/v1.0/tms/trace/id",
        query: {
          equal: tmsOrderId
        },
        action: (res) => {
          if (res.data.code === 20000) {
            this.traceVo = res.data.data
            if(this.traceVo && this.traceVo.logisticsTrace) {
              this.dataGrid = JSON.parse(this.traceVo.logisticsTrace)
            }
          } else {
            this.$Notice.warning({
              title: "获取失败",
              desc: `失败原因：${res.data.msg}`,
            });
          }
        },
      }).get()
    },
    timestampToTime(timestamp) {
      return this.$date(timestamp,'yyyy-MM-dd HH:mm:ss');
    },
  },
};
</script>
<style lang="less" scoped>
.page {
  width: 100%;
}
.head {
  width: 100%;
}
.head-title {
  font-size: 20px;
  height: 40px;
  font-weight: bold;
}
.head-box {
  display: flex;
  width: 100%;
  justify-content: space-between;
  min-height: 30px;
}
.head-box .box-item:nth-child(1) {
  width: 30%;
}
.head-box .box-item:nth-child(2) {
  width: 30%;
}
.head-box .box-item:nth-child(3) {
  width: 40%;
}
.btns{
  margin: 16px 0px;
}
.item-image{
  display: flex;
  align-items: flex-start;
}
</style>